/**
 * yuechao
 * 
 */
function loading() {
	var contextPath = $('#contextPath').val();
	var result_loading = '<img src="' + contextPath + '/images/load.gif" />&nbsp;Processing ...';

	$("#result").html(result_loading);
};

function showMsg(msg) {
	$("#result").html(msg);
};

function showResult(result, filename, videoUrl) {
	$("#result").html('');
	$('#filename').html(filename);
	$('#result').html(result);
	$('#btnDownload')[0].href= videoUrl;
	$('#divDownload').css('display','block');
};

function setDownloadUrl(object){
	var urlValue = object.value;
	var filename = $("#filename").html();
	var index1 = filename.lastIndexOf('.');
	var index2 = urlValue.lastIndexOf('.');
	var ext=0;
	if(index1 >= 0){
		filename = filename.substring(0,index1);
	}
	if(index2 >= 0){
		ext = urlValue.substring(index2);
	}
	filename += ext;
	$("#filename").html(filename);
	$('#btnDownload')[0].href= urlValue.substring(0, index2) + "&title=" + encodeURIComponent(filename.substring(0,index1));
};

function isJreInstalled() {
	if(navigator.userAgent.indexOf('MSIE') > -1) {
		try {
			new ActiveXObject('JavaWebStart.isInstalled');
			return true;
		} catch(e) {
			return false;
		}
	}
	
	var b = navigator.mimeTypes 
	 	&& navigator.mimeTypes.length 
	 	&& (navigator.mimeTypes['application/x-java-jnlp-file'] != null 
	 			|| navigator.mimeTypes['application/x-java-vm'] != null);
	
	var c = navigator.javaEnabled();
	if (c == false) {
		return c;
	} 

	return b;
}
